package genericity;

class Holder<T> {
    private T t;
    public T get() {
        return t;
    }

    public void set(T t) {
        this.t = t;
    }
}

class Holder1 {
    private Object t;
    public Object get() {
        return t;
    }
    public void set(Object t) {
        this.t = t;
    }
}

/**
 * 测试泛型擦除
 */
public class Test1 {
    public static void main(String[] args) {
        Holder<String> holder = new Holder<>();
        holder.set("hello");
        String s = holder.get();
        System.out.println(s);
    }
}

class Test2 {
    public static void main(String[] args) {
        Holder1 holder1 = new Holder1();
        holder1.set("hello");
        String s = (String) holder1.get();
        System.out.println(s);
    }
}
